package m.jclecai.com.view;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.view.View;
import android.widget.TextView;

import m.jclecai.com.activity.WebHelperActivity;
import m.jclecai.com.constant.Constant_Url;

/**
 * Created by hp on 2017/3/27.
 */

public class MyClickText extends ClickableSpan {

    public Activity context;

    public MyClickText(Activity context) {
        this.context = context;
    }

    @Override
    public void updateDrawState(TextPaint ds) {
        super.updateDrawState(ds);
        //设置文本的颜色
        ds.setColor(Color.parseColor("#ffa6d1fd"));//设置字体颜色
        ds.setUnderlineText(false);//去掉下划线
        ds.clearShadowLayer();//清除阴影层

    }

    @Override
    public void onClick(View widget) {
      //  MyToast.showToast(context,"我可以点击了");
        avoidHintColor(widget);
        Intent intent = new Intent(context, WebHelperActivity.class);
        intent.putExtra("code", Constant_Url.REGISTCODE_URL);
        intent.putExtra("title", "协议");
        context.startActivity(intent);
    }
    private void avoidHintColor(View view){
        if(view instanceof TextView)
            ((TextView)view).setHighlightColor(context.getResources().getColor(android.R.color.transparent));
    }
}
